package com.aye.haze_detection;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.amap.api.maps.offlinemap.City;

public class MyService extends Service {
    private static final String TAG = MyService.class.getSimpleName();
    private String City;
    private String CityId;
    private String Weather;
    private String AirAqi;
    public MyService() {


    }



    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        City = intent.getStringExtra("city");
        CityId = intent.getStringExtra("cityid");
        Weather = intent.getStringExtra("weather");
        AirAqi = intent.getStringExtra("airaqi");
        Log.d(TAG, "服务器Service: "+" 城市："+City+" 城市ID:"+CityId+" 天气情况："+Weather+" 空气质量指数："+AirAqi);
        //发送静态广播
        Intent intent_broadcast = new Intent();
        intent_broadcast.setAction(ActionUtils.ACTION_FLAG);
        intent_broadcast.putExtra("cityid",CityId);
        sendBroadcast(intent_broadcast);

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        return super.onUnbind(intent);
    }
}